<?php

	class collocate_goods_listener extends pageFactory
	{
		function collocate_goods_listener()
		{
			parent::pageFactory();
			$this->system = &$GLOBALS['system'];
			$this->db = &$this->system->database();
		}

		function save($args,$data)
		{
			$pValue = $data['collocation'];
			$objGoods = $this->system->loadModel('trading/goods');
			//处理搭配商品
			foreach ($data['collocation']['name'] as $key => $name)
			{
				$aItem['name'] = $name;
				$aItem['type'] = $data['collocation']['type'][$key];
				$aItem['min_num'] = $data['collocation']['min_num'][$key];
				$aItem['max_num'] = $data['collocation']['max_num'][$key];
				$aItem['set_price'] = $data['collocation']['set_price'][$key];
				$aItem['price'] = $data['collocation']['price'][$key];
				$aItem['isForce'] = $data['collocation']['isForce'][$key];
				$aItem['isShowOriPrice'] = $data['collocation']['isShowOriPrice'][$key];
				$aItem['isShowSaving'] = $data['collocation']['isShowSaving'][$key];
				$aItem['items'] = $data['collocation']['items'][$key];
				$aCollacation[$key] = $aItem;
			}
			$objGoods->setGoodsMemo($data['goods_id'],'collocation',$aCollacation);
		}
	}

?>